package swordoffer.offer15;

public class BitRightMove {
    public int hammingWeight(int n) {
        int res = 0;
        while (n != 0) {
            // 取出该二进制数末尾的值
            // res += (n & 1) == 1 ? 1 : 0;
            res += n & 1;
            // 逻辑右移 1 位
            n = n >>> 1;
        }
        return res;
    }

    public static void main(String[] args) {
        System.out.println(-1 >> 1);
        System.out.println(-1 >>> 1);
    }
}
